﻿myApp.controller("CalcConvertController", function ($scope, $http, $modal, modalService, $routeParams, $location, $filter,$compile, NgMap) {
    document.title = "Penang Realty 世界地產 Tenancy Calculator";
    $scope.$emit('newPageLoaded', { 'title': 'Penang Realty 世界地產 Conversion Calculator', 'description': 'Free online Conversion calculator. Try it now.' });
    
    $scope.selectedItem = {};
    $scope.convertList = [{
        'id': 1,
        'base': 'Hectare',
        'convertUnit': 'Acres',
        'formula' : 2.471,
        'name': 'Hectare - Acres',

    }, {
        'id': 2,
        'base': 'Acre',
        'convertUnit': 'Sq Feet',
        'formula': 43560,
        'name': 'Acre - Sq Feet',
    }, {
        'id': 3,
        'base': 'Acre',
        'convertUnit': 'Meter Sq',
        'formula': 4046.86,
        'name': 'Acre - Meter Sq',
    }, {
        'id': 4,
        'base': 'Relong',
        'convertUnit': 'Sq Feet',
        'formula': 30976,
        'name': 'Relong - Sq Feet',
    }, {
        'id': 5,
        'base': 'Meter Sq',
        'convertUnit': 'Sq Feet',
        'formula': 10.7639,
        'name': 'Meter Sq - Sq Feet',
    }, {
        'id': 6,
        'base': 'Rantai',
        'convertUnit': 'Feet',
        'formula': 66,
        'name': 'Rantai - Feet',
    }, {
        'id': 7,
        'base': 'Meter',
        'convertUnit': 'Feet',
        'formula': 3.281,
        'name': 'Meter - Feet',
    }, {
        'id': 8,
        'base': 'Milimeter',
        'convertUnit': 'Feet',
        'formula': 0.003281,
        'name': 'Milimeter - Feet',
    }];

    $scope.changePage = function () {

    }

    $scope.inputKeyUp = function () {

        $scope.baseOutput = $scope.baseInput * $scope.selectedItem.formula;
    }

    $scope.outputKeyUp = function () {  

        $scope.baseInput = $scope.baseOutput / $scope.selectedItem.formula;
    }

    $scope.selectedItem = $scope.convertList[0];

    $scope.initSelect = function () {

        console.log($scope.selectedItem);
    }
})